home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
MWCC03.ZIP
/
RTL.ZIP
/
MMSGBOX.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-08-18
|
15KB
|
511 lines
{**********************************************************************}
{* *}
{* Microworks Custom Control Object Library *}
{* *}
{* Version 1.03 *}
{* *}
{* Object Windows Library Extension for Borland Pascal v7.0 *}
{* *}
{* and Turbo Pascal for Windows v 1.5 *}
{* *}
{* MMsgBox : Message Box Unit *}
{* *}
{* Copyright 1992-93 Microworks (Jeff Franks) Sydney, Australia. *}
{* *}
{**********************************************************************}
unit MMsgBox;
interface
uses WinProcs, WinTypes;
type
TMinMaxInfo = array [0..4] of TPoint;
PMinMaxInfo = ^TMinMaxInfo;
function MWCCMsgBox (WndParent: HWnd; ATxt, ACaption: PChar; ATextType: Word;
ABmp: PChar): Integer;
function SFXMsgBox (WndParent: HWnd; ATxt, ACaption: PChar; ATextType: Word): Integer;
function CreateDefaultFont (IsBold: Boolean): HFont;
procedure Draw3DBorder (Wnd: HWnd; X, Y, W, H: Integer; Shade: Word);
procedure DrawSFXFrame (Wnd: HWnd);
procedure DrawMsgBoxButton (Wnd: HWnd; lParam: LongInt);
procedure MsgBoxKeyDown (ParentWnd, Wnd: HWnd; wParam: Word);
procedure PaintMsgBox (Wnd: HWnd; AText: PChar; Ofs1, Ofs2, Ofs3: Integer;
MsgBmp: HBitmap; SFXStyle: Boolean);
implementation
const
ctl_Recessed = 51;
var
Default1 : Boolean;
Default2 : Boolean;
Default3 : Boolean;
SFXStyle : Boolean;
BkBmp : HBitmap;
MsgBmp : HBitmap;
UpBmp1 : HBitmap;
UpBmp2 : HBitmap;
UpBmp3 : HBitmap;
BkBrush : HBrush;
LastWnd : HWnd;
MsgBoxWnd : HWnd;
WndButton1 : HWnd;
WndButton2 : HWnd;
WndButton3 : HWnd;
ID1 : Integer;
ID2 : Integer;
ID3 : Integer;
a : Integer;
b : Integer;
c : Integer;
d : Integer;
e : Integer;
f : Integer;
Reply : Integer;
ButtonProc1 : TFarProc;
ButtonProc2 : TFarProc;
ButtonProc3 : TFarProc;
OldProc1 : TFarProc;
OldProc2 : TFarProc;
OldProc3 : TFarProc;
HLib : THandle;
MWCCWndHdl : THandle;
SFXWndHdl : THandle;
WinRect : TRect;
TextType : Word;
szText : array[0..255] of Char;
szTitle : array[0..50] of Char;
{********** External functions and procedures **********}
function CreateDefaultFont; external 'MWCC' Index 1;
procedure Draw3DBorder; external 'MWCC' Index 5;
procedure DrawSFXFrame; external 'MWCC' Index 10;
procedure DrawMsgBoxButton; external 'MWCC' Index 11;
procedure MsgBoxKeyDown; external 'MWCC' Index 12;
procedure PaintMsgBox; external 'MWCC' Index 13;
{********** MWCCMsgBox and SFXMsgBox **********}
procedure InitializeData;
begin
Default1 := False;
Default2 := False;
Default3 := False;
SFXStyle := False;
BkBmp := 0;
MsgBmp := 0;
UpBmp1 := 0;
UpBmp2 := 0;
UpBmp3 := 0;
BkBrush := 0;
LastWnd := 0;
MsgBoxWnd := 0;
WndButton1 := 0;
WndButton2 := 0;
WndButton3 := 0;
ID1 := 0;
ID2 := 0;
ID3 := 0;
a := 0;
b := 0;
c := 0;
d := 0;
e := 0;
f := 0;
ButtonProc1 := nil;
ButtonProc2 := nil;
ButtonProc3 := nil;
OldProc1 := nil;
OldProc2 := nil;
OldProc3 := nil;
HLib := 0;
MWCCWndHdl := 0;
SFXWndHdl := 0;
end;
function MsgBoxButton1Proc (Wnd: HWnd; Message, wParam: Word; lParam: Longint): Longint; export;
begin
MsgBoxButton1Proc := 0;
case Message of
wm_KeyDown : MsgboxKeyDown(MsgBoxWnd, Wnd, wParam);
end;
MsgBoxButton1Proc := CallWindowProc (OldProc1, Wnd, Message, wParam, lParam);
end;
function MsgBoxButton2Proc (Wnd: HWnd; Message, wParam: Word; lParam: Longint): Longint; export;
begin
MsgBoxButton2Proc := 0;
case Message of
wm_KeyDown : MsgboxKeyDown(MsgBoxWnd, Wnd, wParam);
end;
MsgBoxButton2Proc := CallWindowProc (OldProc2, Wnd, Message, wParam, lParam);
end;
function MsgBoxButton3Proc (Wnd: HWnd; Message, wParam: Word; lParam: Longint): Longint; export;
begin
MsgBoxButton3Proc := 0;
case Message of
wm_KeyDown : MsgboxKeyDown(MsgBoxWnd, Wnd, wParam);
end;
MsgBoxButton3Proc := CallWindowProc (OldProc3, Wnd, Message, wParam, lParam);
end;
function MsgBoxProc(Wnd: HWnd; Message, wParam: Word; lParam: Longint): Longint; export;
type
NCRect = array[0..2] of TRect;
PRect = ^NCRect;
var
MinMaxInfo : PMinMaxInfo;
begin
MsgBoxProc := 0;
case Message of
wm_Destroy:
begin
if HLib >= 32 then FreeLibrary(HLib);
if BkBmp <> 0 then
begin
DeleteObject(BkBmp);
DeleteObject(BkBrush);
end;
if MsgBmp <> 0 then DeleteObject(MsgBmp);
if UpBmp1 <> 0 then DeleteObject(UpBmp1);
if UpBmp2 <> 0 then DeleteObject(UpBmp2);
if UpBmp3 <> 0 then DeleteObject(UpBmp3);
PostQuitMessage(0);
Exit;
end;
wm_Paint:
begin
PaintMsgBox (Wnd, szText, a, e, f, MsgBmp, SFXStyle);
if SFXStyle then DrawSFXFrame(Wnd);
end;
wm_DrawItem: DrawMsgBoxButton(Wnd, lParam);
wm_Command:
begin
if HiWord(lParam) = bn_Clicked then
begin
Reply := wParam;
EnableWindow(LastWnd, True);
SetFocus(LastWnd);
DestroyWindow(Wnd);
if SFXStyle then
UnregisterClass('SFXMsgBoxWindow', SFXWndHdl)
else
UnregisterClass('MWCCMsgBoxWindow', MWCCWndHdl);
end;
end;
wm_NCPaint:
begin
if SFXStyle then
begin
DrawSFXFrame(Wnd);
GetWindowText(Wnd, szTitle, sizeof(szTitle));
SetWindowText(Wnd, szTitle);
MsgBoxProc := 1;
Exit;
end;
end;
wm_NCCalcSize: if SFXStyle then Inc(PRect(lParam)^[0].Top, 1);
wm_Activate: if SFXStyle then DrawSFXFrame(Wnd);
wm_NCActivate: if SFXStyle then DrawSFXFrame(Wnd);
wm_ActivateApp: if SFXStyle then DrawSFXFrame(Wnd);
wm_GetMinMaxInfo:
begin
longInt(MinMaxInfo) := lParam;
GetWindowRect(Wnd, WinRect);
if ((WinRect.Right-WinRect.Left) > 36) and ((WinRect.Bottom-WinRect.Top) > 36) then
begin
MinMaxInfo^[1].X := WinRect.Right - WinRect.Left;
MinMaxInfo^[1].Y := WinRect.Bottom - WinRect.Top;
MinMaxInfo^[3].X := WinRect.Right - WinRect.Left;
MinMaxInfo^[3].Y := WinRect.Bottom - WinRect.Top;
MinMaxInfo^[4].X := WinRect.Right - WinRect.Left;
MinMaxInfo^[4].Y := WinRect.Bottom - WinRect.Top;
end;
end;
end;
MsgBoxProc := DefWindowProc(Wnd, Message, wParam, lParam);
end;
procedure MsgBoxWinMain (WndParent: HWnd; ATxt, ACaption: PChar; ATextType: Word; ABmp: PChar);
label
CaseExit;
const
MWCCWndClass : TWndClass = (style : 0;
lpfnWndProc : @MsgBoxProc;
cbClsExtra : 0;
cbWndExtra : 0;
hInstance : 0;
hIcon : 0;
hCursor : 0;
hbrBackground : 0;
lpszMenuName : nil;
lpszClassName : 'MWCCMsgBoxWindow');
SFXWndClass : TWndClass = (style : 0;
lpfnWndProc : @MsgBoxProc;
cbClsExtra : 0;
cbWndExtra : 0;
hInstance : 0;
hIcon : 0;
hCursor : 0;
hbrBackground : 0;
lpszMenuName : nil;
lpszClassName : 'SFXMsgBoxWindow');
var
SysMenu : HMenu;
FocusWnd : HWnd;
W : Integer;
H : Integer;
XScreen : Integer;
YScreen : I